//
// Created by user on 2022/2/28.
//
#include <vector>
using namespace std;
string simplifyPath(string path) {
    vector<string> st;
    stringstream ss(path);
    string dir;
    while (getline(ss, dir, '/')){
        if(dir==""||dir==".")continue;
        else if(dir==".." && st.empty())continue;
        else if(dir==".." && !st.empty())st.pop_back();
        else st.push_back(dir);
    }
    if(st.empty())return "/";
    string res;
    for(auto dir: st)res+="/"+dir;
    return res;
}